import * as THREE from 'three'
import './style.css'
import {camera ,sizes} from './camera';
import {controls} from './control';
import {ambientLight,
  // spotLight
} from './light/ambientLight';
import {renderer} from './renderer';
import {gridHelper,axes} from './helper/index';
import { girdPlane } from './geometry/girdPlane';
import { groupCompany} from './geometry/company';
import { groupWorkShop} from './geometry/workshop';
import { groupProdline} from './geometry/prodline';

const scene = new THREE.Scene()


const spotLight = new THREE.SpotLight(0xff4400,1);
spotLight.position.set(10, 3, 10);
spotLight.castShadow = true;
const spotLightHelper = new THREE.SpotLightHelper(spotLight)






// 场景基本要素
scene.add(gridHelper)
scene.add(axes)
scene.add(camera)

// 光源
scene.add(ambientLight);
scene.add(spotLight);
scene.add(spotLightHelper);


// 物体
scene.add(girdPlane);
// let arr = [1,2,3,4,5,6,7]
// for (let i = 0; i < arr.length; i++) {
//   const cur = arr[i];
  let curGeo = groupWorkShop.children
  // curGeo.position.x = 3.1 * (i + 15)
  console.log(groupWorkShop);
  console.log(groupWorkShop.children);
//   scene.add(curGeo)
// }
// scene.add(groupCompany)
scene.add(groupWorkShop)
scene.add(groupProdline)

renderer.setSize(sizes.width, sizes.height)
// 开启阴影
render.shadowMapEnabled = true;
render.shadowMap = 0;  



var invert = 1;
var phase = 0; 
function render(time) {
  time *= 0.001;  // 将时间单位变为秒
  // groupWorkShop.rotation.x = time;
  // groupWorkShop.rotation.y = time;
  // groupWorkShop.rotation.z = time;
  
  controls.update();
  renderer.render(scene, camera);
  requestAnimationFrame(render);
}
requestAnimationFrame(render);



window.addEventListener('resize',function () {
    camera.aspect = window.innerWidth/window.innerHeight;
    camera.updateProjectionMatrix()
    renderer.setSize(window.innerWidth, window.innerHeight)
})
console.log(scene.children);
